package push.totop.filenamechange

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView

class MyAdapter constructor(val myData: MutableList<String>, val c: Context) : BaseAdapter() {


    override fun getView(p0: Int, p1: View?, p2: ViewGroup?): View {
        var holder:MyViewHolder
        var v: View
//        print("at index:$p0")
//        p1?.setOnClickListener { click() }
        if (p1 == null) {
            holder = MyViewHolder()
            v = LayoutInflater.from(c).inflate(android.R.layout.simple_list_item_1, p2, false)
            holder.textView= v.findViewById(android.R.id.text1) as TextView
            v.tag = holder
        } else {
            v = p1
            holder = v.tag as MyViewHolder
        }

        holder.textView.text = myData[p0]
        return v
    }

    class MyViewHolder {
        lateinit var textView: TextView

    }

    override fun getItem(p0: Int): Any {
        return p0

    }

    override fun getItemId(p0: Int): Long {
        return p0.toLong()
    }

    override fun getCount(): Int {
        return myData.size
    }

    private fun click() {
        print("+++++++++++++")

    }
}